#pragma once
#include "GameModuleDependence.h"
#include "aenginemodule.h"
#include "MessageReceiver.h"
#include "MessageSender.h"
//#include "ObjectMessageManager.h"


namespace _MODULE_
{
	namespace _GAME_
	{

		

		class GameModule
			:public _FOGGE_::aEngineModule, 
			public _FOGGE_::_MSG_::MessageReceiver<GameModule> ,
			public _FOGGE_::_MSG_::MessageSender
		{
		public:
			GameModule(void);
			~GameModule(void);
			virtual void PostUpdate(float elapsedtime);
			virtual void Update(float elapsedtime);

			virtual bool SystemInitialize();
			virtual void SystemFinalize();
			virtual bool Initialize();
			virtual void Finalize(){}


		protected:


			HRESULT OnGameControllCommand(_FOGGE_::_MSG_::Message* ptrMsg,_FOGGE_::_MSG_::Message* ptrRetMsg);
			HRESULT OnDataLoaded(_FOGGE_::_MSG_::Message* ptrMsg,_FOGGE_::_MSG_::Message* ptrRetMsg);
			HRESULT OnDataRemoved(_FOGGE_::_MSG_::Message* ptrMsg,_FOGGE_::_MSG_::Message* ptrRetMsg);
			HRESULT OnDataModified(_FOGGE_::_MSG_::Message* ptrMsg,_FOGGE_::_MSG_::Message* ptrRetMsg);


		/**
		Collision Message handlers
		*/
		//@{
			HRESULT OnCollisionCheckResult(_FOGGE_::_MSG_::Message* ptrMsg,_FOGGE_::_MSG_::Message* ptrRetMsg);
		//@}
	
			//ObjectMessageManager* m_ptrObjectMessageManager;
			std::list<_FOGGE_::foString> m_GameControllCommandList;
			
			std::vector<LocalController*> m_LocalControllerVector;
			std::vector<RemoteController*> m_RemoteControllerVector;

			GameSimulator* m_ptrGameSimulator;

		private:
			void UpdateGameCommands(float elapsedtime);
			void UpdateGameParts(float elapsedtime);


			
			float m_fAccumulatedGameCommandTime;
			std::set<_P_GAME::GamePart*> m_setGamePart;

			
	
		};
	}
}